﻿using System;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

// Token: 0x020003B2 RID: 946
[RequireComponent(typeof(Toggle))]
public class MoveableToggle : MonoBehaviour
{
	// Token: 0x06001798 RID: 6040 RVA: 0x0009C3C0 File Offset: 0x0009A5C0
	private void Awake()
	{
		this.toggle = base.GetComponent<Toggle>();
		this.moveableUI.onChangeState.AddListener(new UnityAction<MoveableUI.STATE>(this.OnChangeState));
		this.toggle.onValueChanged.AddListener(new UnityAction<bool>(this.OnToggleChange));
	}

	// Token: 0x06001799 RID: 6041 RVA: 0x0009C414 File Offset: 0x0009A614
	private void Update()
	{
	}

	// Token: 0x0600179A RID: 6042 RVA: 0x0009C418 File Offset: 0x0009A618
	private void OnToggleChange(bool flag)
	{
		if (!this.invoke)
		{
			return;
		}
		if (flag)
		{
			this.moveableUI.Open();
		}
		else
		{
			this.moveableUI.Close();
		}
	}

	// Token: 0x0600179B RID: 6043 RVA: 0x0009C448 File Offset: 0x0009A648
	private void OnChangeState(MoveableUI.STATE state)
	{
		this.invoke = false;
		this.toggle.isOn = (this.moveableUI.State != MoveableUI.STATE.CLOSED);
		this.invoke = true;
	}

	// Token: 0x04001B2C RID: 6956
	[SerializeField]
	private MoveableUI moveableUI;

	// Token: 0x04001B2D RID: 6957
	private Toggle toggle;

	// Token: 0x04001B2E RID: 6958
	private bool invoke = true;
}
